"""Added CheckMessage model, model check and get tasks time to UserCalendar, added media_filename to CalendarTask

Revision ID: 1285335a7541
Revises: 224e3fe44bb2
Create Date: 2023-12-04 12:18:01.978043

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "1285335a7541"
down_revision = "224e3fe44bb2"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "check_message",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("text_ru", sa.TEXT(), nullable=False),
        sa.Column("text_en", sa.TEXT(), nullable=False),
        sa.Column("text_uk", sa.TEXT(), nullable=False),
        sa.Column("media_filename", sa.String(length=255), nullable=True),
        sa.Column("calendar_id", sa.Integer(), nullable=False),
        sa.Column(
            "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.Column(
            "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=True
        ),
        sa.ForeignKeyConstraint(
            ["calendar_id"],
            ["calendar.id"],
            name=op.f("fk_check_message_calendar_id_calendar"),
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_check_message")),
    )
    op.add_column(
        "calendar_task",
        sa.Column("media_filename", sa.String(length=255), nullable=True),
    )
    op.drop_column("user", "check_tasks_time")
    op.drop_column("user", "get_tasks_time")
    op.add_column(
        "user_calendar",
        sa.Column(
            "check_tasks_time", sa.Time(), server_default="19:00", nullable=False
        ),
    )
    op.add_column(
        "user_calendar",
        sa.Column("get_tasks_time", sa.Time(), server_default="18:00", nullable=False),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("user_calendar", "get_tasks_time")
    op.drop_column("user_calendar", "check_tasks_time")
    op.add_column(
        "user",
        sa.Column(
            "get_tasks_time",
            mysql.TIME(),
            server_default=sa.text("'18:00:00'"),
            nullable=False,
        ),
    )
    op.add_column(
        "user",
        sa.Column(
            "check_tasks_time",
            mysql.TIME(),
            server_default=sa.text("'19:00:00'"),
            nullable=False,
        ),
    )
    op.drop_column("calendar_task", "media_filename")
    op.drop_table("check_message")
    # ### end Alembic commands ###
